Ext.namespace('mdmp.catalog');
Ext.QuickTips.init();// 为组件提供提示信息功能，form的主要提示信息就是客户端验证的错误信息。
var searchForm = "";
var searchForm2 = "";
var Grid = "";
var Grid2="";


mdmp.catalog.main = function() {
	return {
		init : function() {
			this.initSearchform();
			this.initMainGrid();
			this.initViewPort();
		},
		initSearchform : function() {
			
			
			
			var orgComb1=new Ext.form.ComboBox({
			    fieldLabel:'条件一',
			    mode : 'local',
		        triggerAction : 'all',
		        editable :false, 
		        displayField : 'TEXT',
		        valueField : 'ID',
		        width:200,
		        store: new Ext.data.ArrayStore({
					fields:[
					        'ID',
					        'TEXT'
					],
					data:[["0","BRAND_ID"],["1","BRAND_NAME"]]
				})/*,
				listeners :{
					expand :function(){
			        	Ext.getCmp('sex1').reset() ; 
			        }
				}*/
		});
	
			var orgComb2=new Ext.form.ComboBox({
			    fieldLabel:'条件二',
			    mode : 'local',
		        triggerAction : 'all',
		        editable :false, 
		        displayField : 'TEXT',
		        valueField : 'ID',
		        width:200,
		        store: new Ext.data.ArrayStore({
					fields:[
					        'ID',
					        'TEXT'
					],
					data:[["0","BRAND_ID"],["1","BRAND_NAME"]]
				})/*,
				listeners :{
					expand :function(){
			        	Ext.getCmp('sex1').reset() ; 
			        }
				}*/
		});  	
			
			
			var orgComb3=new Ext.form.ComboBox({
			    fieldLabel:'卷烟规格',
			    mode : 'local',
		        triggerAction : 'all',
		        editable :false, 
		        displayField : 'TEXT',
		        valueField : 'ID',
		        width:200,
		        store: new Ext.data.ArrayStore({
					fields:[
					        'ID',
					        'TEXT'
					],
					data:[["0","全选"],["1","中南海(金8mg)"],["2","中南海(软蓝色时光)"],["3","中南海(软精品)"],["4","钻石(时尚)"]]
				})/*,
				listeners :{
					expand :function(){
			        	Ext.getCmp('sex1').reset() ; 
			        }
				}*/
		});  	
			
			var orgComb4=new Ext.form.ComboBox({
			    fieldLabel:'客户经理',
			    mode : 'local',
		        triggerAction : 'all',
		        editable :false, 
		        displayField : 'TEXT',
		        valueField : 'ID',
		        width:200,
		        store: new Ext.data.ArrayStore({
					fields:[
					        'ID',
					        'TEXT'
					],
					data:[["0","全选"],["1","翁颖毅"],["2","陈江晔"],["3","梁丽华"],["4","徐丽萍"]]
				})/*,
				listeners :{
					expand :function(){
			        	Ext.getCmp('sex1').reset() ; 
			        }
				}*/
		}); 
			
			
			
			searchForm = new Ext.form.FormPanel({
				frame : true,
				border : true,
				labelAlign : 'right',
				region : 'north',
				height:130,
				layout : 'form',
				
				items:[{layout:'form',style:'margin-top:20px',items:[
				{style:'margin-top:5px',layout:'column',items:[{columnWidth:.4,layout:'form',items:{fieldLabel : '开始日期',xtype : 'datefield',width : 200,format : 'Y-m-d'}},{columnWidth:.4,layout:'form',items:{fieldLabel : '结束日期',xtype : 'datefield',width : 200,format : 'Y-m-d'}}]
					
					},{layout:'column',items:[{columnWidth:.4,layout:'form',items:[orgComb3]},{columnWidth:.4,layout:'form',items:[orgComb4]}]
					
					}]
				    }],
				   bbar:['->',{
						id:'before',
						text : "查询",
						iconCls : 'silk_page_find'
					}] 

			});
			
			searchForm2 = new Ext.form.FormPanel({
				frame : true,
				border : true,
				labelAlign : 'right',
				region : 'center',
				height:130,
				layout : 'form',
				
				items:[{    xtype: 'box', //或者xtype: 'component',   
					   width: 1080,  
					   id: 'imagebox',  
					   name: 'imagebox',  
					   height: 400,    
					   autoEl: {  
					   tag: 'img',    //指定为img标签       
					   src: '/Demo3/images/baobiao.png'    //指定url路径       
					    }      }]
				  

			});


	


	

		},
		initMainGrid : function() {
			var data = [  
			          　　{"_id":1,"text":"营销分析主题","_parent":null,"_is_leaf":false},  
			          　　{"_id":2,"text":"卷烟销售按月组合分析","_parent":1,"_is_leaf":true},
			          {"_id":3,"text":"客户销售按月组合分析","_parent":1,"_is_leaf":true},  
			          {"_id":4,"text":"品牌订足率订足面表2","_parent":1,"_is_leaf":true} ,
			          {"_id":5,"text":"漳州客户卷烟订单组合分析","_parent":1,"_is_leaf":true}  
			          ];  
			          var record = Ext.data.Record.create([  
			          　　{name: '_id', type: 'int'},  
			         {name: 'text', type: 'string'}, 
			           　   {name: '_parent', type: 'int'}, 
			          　　{name: '_is_leaf', type: 'bool'},  
			          　　
			          ]);  
			        var store = new Ext.ux.maximgb.tg.AdjacencyListStore({  
			          　　reader: new Ext.data.JsonReader({id: '_id'}, record),  
			          　　proxy: new Ext.data.MemoryProxy(data)  
			          });  
			
			
			 Grid=new Ext.ux.maximgb.tg.GridPanel({
				 width:200,
				 region:'west',
				 master_column_id : 'text',
			     stripeRows : true,
			     autoScroll : true,
			     loadMask : {msg : '正在查询，请稍候...'},
			     cm: new Ext.grid.ColumnModel([
			     	         {
			     	        	 width:200,
		                        header : '<center>目录</center>',
		                        dataIndex : 'text',
		                        align : 'center',
		                        id:'text'
		                    }
			     ]),
			     store:store
			});	
			 
			 
		

				
				
				var cm2 = new Ext.grid.ColumnModel([ {
					header : '<center>结果一</center>',
					dataIndex : 'TRADE_CODE',
					algin : 'center',
						width:170
				},{
					header : '<center>结果二</center>',
					dataIndex : 'TRADE_NAME',
					algin : 'center',
						width:170
				}, {
					header : '<center>结果三</center>',
					dataIndex : 'UPDATE_TIME',
					algin : 'center',
					width:170
				}, {
					header : '<center>结果三</center>',
					dataIndex : 'UPDATE_TIME',
					algin : 'center',
					width:170
				}

				]);
				
				var store2 = new Ext.data.Store({
					proxy : new Ext.data.HttpProxy({
						url :'${path}/StmatradeController/Allselect.do'
					}),
					autoLoad : false,
					reader : new Ext.data.JsonReader({
						root : 'items',
						totalProperty : 'totalCount',
						fields : [ 'TRADE_CODE','TRADE_NAME', 'UPDATE_TIME']
					})
				});
				
				
				
				Grid2 = new Ext.grid.GridPanel({
					cm : cm2,
					region : 'center',
					store : store2,
					autoScroll : true,
					loadMask : {
						msg : '正在查询，请稍候...'
					}/*,
					bbar:new Ext.PagingToolbar({
			        	pageSize :Ext.mdm.getPageSize(),
						store : store,
						displayMsg :"第{0}-{1}条记录，共{2}条记录"

			        })*/
				});	 
			 
			 
			

		},
		initViewPort : function() {

			
			var panel = new Ext.Panel({
				frame : true,
				border : true,
				region:'center',
				layout : 'border',
				
				items : [ searchForm2, searchForm]
			

			});
			
			var win = new Ext.Window({
				title:"参数选择",
				frame : true,
				border : true,
				layout : 'border',
				items : [ Grid,panel]
			});

			var viewPort = new Ext.Viewport({
				layout : 'fit',
				items : [ win ]
			});
			 win.on('show',function(){
		            
	            	Grid.getStore().load();
	            });
			win.show();
			viewPort.render();
		
			
	
			
			
			
		}
		
	};

}();
Ext.onReady(mdmp.catalog.main.init, mdmp.catalog.main);


